surface: Start sketching a new surface type
authorMatthias Clasen <mclasen@redhat.com>
Wed, 20 Mar 2019 00:05:17 +0000 (20:05 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 28 May 2019 20:25:13 +0000 (20:25 +0000)
Start by adding a constructor. We have to call it
gdk_surface_new_popup_full for now, since gdk_surface_new_popup
is taken. This may be reshuffled later.

gdk/gdksurface.c
gdk/gdksurface.h

index 2ad20b169b251cf43005ff64e97c574c53dc2518..1a8587e5f8de6b21b582f4d88280bd851dda2d3b 100644 (file)
@@ -836,6 +836,42 @@ gdk_surface_new_popup (GdkDisplay         *display,
   return gdk_surface_new (display, NULL, &attr);
 }
 
+/**
+ * gdk_surface_new_popup_full: (constructor)
+ * @display: the display to create the surface on
+ * @parent: the parent surface to attach the surface to
+ *
+ * Create a new popup surface.
+ * The surface will be attached to @parent and can
+ * be positioned relative to it using
+ * gdk_surface_move_to_rect().
+ *
+ * Returns: (transfer full): a new #GdkSurface
+ */
+GdkSurface *
+gdk_surface_new_popup_full (GdkDisplay *display,
+                            GdkSurface *parent)
+{
+  GdkSurface *surface;
+  GdkSurfaceAttr attr;
+
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+  g_return_val_if_fail (GDK_IS_SURFACE (parent), NULL);
+
+  attr.wclass = GDK_INPUT_OUTPUT;
+  attr.x = 0;
+  attr.y = 0;
+  attr.width = 100;
+  attr.height = 100;
+  attr.surface_type = GDK_SURFACE_TEMP;
+
+  surface = gdk_surface_new (display, NULL, &attr);
+  gdk_surface_set_transient_for (surface, parent);
+  gdk_surface_set_type_hint (surface, GDK_SURFACE_TYPE_HINT_MENU);
+
+  return surface;
+}
+
 /**
  * gdk_surface_new_temp: (constructor)
  * @display: the display to create the surface on
index e35a867af74cb41efbecf387459533261a7ca12a..f3169b5931798e9b6a6eadcffc6c6bf1b20ae1c4 100644 (file)
@@ -440,6 +440,9 @@ GDK_AVAILABLE_IN_ALL
 GdkSurface *   gdk_surface_new_popup            (GdkDisplay    *display,
                                                  const GdkRectangle *position);
 GDK_AVAILABLE_IN_ALL
+GdkSurface *   gdk_surface_new_popup_full       (GdkDisplay    *display,
+                                                 GdkSurface    *parent);
+GDK_AVAILABLE_IN_ALL
 GdkSurface *   gdk_surface_new_temp             (GdkDisplay    *display);
 GDK_AVAILABLE_IN_ALL
 GdkSurface *   gdk_surface_new_child            (GdkSurface     *parent,